package de.karlNet.sambamanager.view.beans;

import org.springframework.stereotype.Controller;

import de.karlNet.sambamanager.ldapModel.LdapObject;

@Controller
public class ViewController {
	private boolean showUserDetails = false;
	private boolean showGroupDetails = false;

	private void setAllViewsToFalse() {
		this.showGroupDetails = false;
		this.showUserDetails = false;
	}

	public boolean isShowUserDetails() {
		return showUserDetails;
	}

	private void setShowUserDetails() {
		this.setAllViewsToFalse();
		this.showUserDetails = true;
	}

	public boolean isShowGroupDetails() {
		return showGroupDetails;
	}

	public void setTypeToShow(LdapObject ldapObject) {
		
		switch (ldapObject.getType()) {
		case LDAP_GROUP:
			this.setShowGroupDetails();
			break;
		case LDAP_USER:
			this.setShowUserDetails();
			break;
		case LDAP_OBJECT:
			break;
		default:
			throw new RuntimeException("Invalid type received - coding error");
		}
	}

	private void setShowGroupDetails() {
		this.setAllViewsToFalse();
		this.showGroupDetails = true;
	}

}
